/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package Client_GUI.Search;

import Client_GUI.Customer.JP_SearchCustomer;
import Client_GUI.SavingBook.JP_SearchSavingBook;
import Client_GUI.SavingType.JP_SearchSavingType;
import Client_GUI.Unity;
import Interface.IRemoteCustomer;
import Server.DTO.Customer_DTO;
import java.rmi.NotBoundException;
import java.rmi.RemoteException;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;

/**
 *
 * @author 10520_000
 */
public class JP_Search extends org.jdesktop.swingx.JXPanel {
    Registry registry;
    IRemoteCustomer rc;
    /**
     * Creates new form JP_AddCusomer
     */
    public JP_Search() throws RemoteException, NotBoundException {
        initComponents();
        registry = LocateRegistry.getRegistry("127.0.0.1");
        rc = (IRemoteCustomer) registry.lookup("Customer");
    }
    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel2 = new javax.swing.JPanel();
        btn_CustomerSearch = new javax.swing.JButton();
        btn_SavingBookSearch = new javax.swing.JButton();
        jXPanel_Present = new org.jdesktop.swingx.JXPanel();
        btn_SavingTypeSearch = new javax.swing.JButton();

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 100, Short.MAX_VALUE)
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 100, Short.MAX_VALUE)
        );

        btn_CustomerSearch.setBackground(new java.awt.Color(255, 255, 255));
        btn_CustomerSearch.setIcon(new javax.swing.ImageIcon(getClass().getResource("/image/60/b_Big_Customer.png"))); // NOI18N
        btn_CustomerSearch.setToolTipText("Tìm Kiếm Thông Tin Khách Hàng");
        btn_CustomerSearch.setBorderPainted(false);
        btn_CustomerSearch.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btn_CustomerSearch.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btn_CustomerSearchActionPerformed(evt);
            }
        });

        btn_SavingBookSearch.setBackground(new java.awt.Color(255, 255, 255));
        btn_SavingBookSearch.setIcon(new javax.swing.ImageIcon(getClass().getResource("/image/60/b_Big_PassBook.png"))); // NOI18N
        btn_SavingBookSearch.setToolTipText("Tìm Kiếm Thông Tin Sổ Tiết Kiệm");
        btn_SavingBookSearch.setBorderPainted(false);
        btn_SavingBookSearch.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btn_SavingBookSearch.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btn_SavingBookSearchActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jXPanel_PresentLayout = new javax.swing.GroupLayout(jXPanel_Present);
        jXPanel_Present.setLayout(jXPanel_PresentLayout);
        jXPanel_PresentLayout.setHorizontalGroup(
            jXPanel_PresentLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 1121, Short.MAX_VALUE)
        );
        jXPanel_PresentLayout.setVerticalGroup(
            jXPanel_PresentLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 578, Short.MAX_VALUE)
        );

        btn_SavingTypeSearch.setBackground(new java.awt.Color(255, 255, 255));
        btn_SavingTypeSearch.setIcon(new javax.swing.ImageIcon(getClass().getResource("/image/60/b_Big_ListPassBook.png"))); // NOI18N
        btn_SavingTypeSearch.setToolTipText("Quản lý loại tiết kiệm");
        btn_SavingTypeSearch.setBorderPainted(false);
        btn_SavingTypeSearch.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btn_SavingTypeSearch.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btn_SavingTypeSearchActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(btn_CustomerSearch, javax.swing.GroupLayout.DEFAULT_SIZE, 122, Short.MAX_VALUE)
                    .addComponent(btn_SavingBookSearch, javax.swing.GroupLayout.DEFAULT_SIZE, 122, Short.MAX_VALUE)
                    .addComponent(btn_SavingTypeSearch, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap(1148, Short.MAX_VALUE))
            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                    .addContainerGap(149, Short.MAX_VALUE)
                    .addComponent(jXPanel_Present, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addContainerGap()))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(btn_CustomerSearch, javax.swing.GroupLayout.PREFERRED_SIZE, 99, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(7, 7, 7)
                .addComponent(btn_SavingBookSearch, javax.swing.GroupLayout.PREFERRED_SIZE, 98, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(btn_SavingTypeSearch, javax.swing.GroupLayout.PREFERRED_SIZE, 98, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(288, Short.MAX_VALUE))
            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                    .addContainerGap()
                    .addComponent(jXPanel_Present, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addContainerGap(23, Short.MAX_VALUE)))
        );
    }// </editor-fold>//GEN-END:initComponents

    private void btn_CustomerSearchActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_CustomerSearchActionPerformed
        // TODO add your handling code here:
        try {
            Unity.AddPanel(jXPanel_Present, new JP_SearchCustomer());
        } catch (RemoteException ex) {
            Logger.getLogger(JP_Search.class.getName()).log(Level.SEVERE, null, ex);
        } catch (NotBoundException ex) {
            Logger.getLogger(JP_Search.class.getName()).log(Level.SEVERE, null, ex);
        } 
    }//GEN-LAST:event_btn_CustomerSearchActionPerformed

    private void btn_SavingBookSearchActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_SavingBookSearchActionPerformed
        // TODO add your handling code here:
         try {
            Unity.AddPanel(jXPanel_Present, new JP_SearchSavingBook());
        }catch (NotBoundException ex) {
            Logger.getLogger(JP_Search.class.getName()).log(Level.SEVERE, null, ex);
        } catch (RemoteException ex) {
            Logger.getLogger(JP_Search.class.getName()).log(Level.SEVERE, null, ex);
        }

    }//GEN-LAST:event_btn_SavingBookSearchActionPerformed

    private void btn_SavingTypeSearchActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_SavingTypeSearchActionPerformed
        // TODO add your handling code here:
        try{
            Unity.AddPanel(jXPanel_Present, new JP_SearchSavingType());
        } catch (Exception e){
            System.out.println(e);
        }
    }//GEN-LAST:event_btn_SavingTypeSearchActionPerformed


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btn_CustomerSearch;
    private javax.swing.JButton btn_SavingBookSearch;
    private javax.swing.JButton btn_SavingTypeSearch;
    private javax.swing.JPanel jPanel2;
    private org.jdesktop.swingx.JXPanel jXPanel_Present;
    // End of variables declaration//GEN-END:variables
}
